<?php

class Core_Backend_Component_Foundation_View_Helper_Poi_List extends Core_Backend_Share_View_Grid {
	
	protected function initialize(){
		parent::initialize();
		$this->setTemplatePath('browser');
	}	

    protected function buildToolbar($toolbar) {
        $group = $toolbar->createGroup('selector');
        $group->addButton($this->__('share.button.selectAll'))
                ->bindEvent('click', "Kdf.Ui.getGrid('" . $this->getGrid()->getId() . "').selectAll()");
        $group->addButton($this->__('share.button.cancelSelected'))
                ->bindEvent('click', "Kdf.Ui.getGrid('" . $this->getGrid()->getId() . "').cancelSelected()");
        $group->addButton($this->__('share.button.selectInverse'))
                ->bindEvent('click', "Kdf.Ui.getGrid('" . $this->getGrid()->getId() . "').selectInverse()");
        $group = $toolbar->createGroup();
        $group->addButton($this->__('share.button.ok'))
              ->bindEvent('click', 'chooseMulti()');
    }

    public function buildGrid($grid) {
        $this->getTemplate()->assign('road_stat', $this->getRoadStat());
        $grid->setId('poi_grid')
                ->setPrimaryKey('id')
                ->setSortField($this->getRequest()->getQuery('sort', 'id'))
                ->setSortDirection($this->getRequest()->getQuery('dir', 'asc'))
                ->setSortUrlFormat($this->getSortUrl());
        $grid->addLabelColumn($this->__('foundation.label.poi_id'), 'poiid', '{id}');
        $grid->addLabelColumn($this->__('foundation.label.shop_name'), 'shopname', '{shop_name}');
//        $grid->addLabelColumn($this->__('share.label.picture'), 'photo', '{photo}')
//                ->setWidth(60);
//        $grid->addLabelColumn($this->__('foundation.label.district'), 'districtname', '{district_name}')
//                ->setTextboxFilter(NULL, NULL, $filter->getData('districtname'))
//                ->setSortField('district_name')
//                ->setWidth(100);
//        $grid->addLabelColumn($this->__('foundation.label.townstreet'), 'townstreetname', '{townstreet_name}')
//                ->setTextboxFilter(NULL, NULL, $filter->getData('townstreetname'))
//                ->setSortField('district_name')
//                ->setWidth(100);
        $grid->addLabelColumn($this->__('foundation.label.road'), 'roadname', '{road_{road_id}}')
                ->setWidth(100);
        $grid->addLabelColumn($this->__('foundation.label.industry'), 'industry', '{industry_{industry_id}}')
                ->setWidth(100);
//        $grid->addLabelColumn($this->__('foundation.label.address'), 'address', '{address}')
//                ->setWidth(300);
        $grid->setDataSource($this->getList()->toArray());
        $grid->setId('choose_poi_grid')
             ->addButtonColumn('#', 'choose', 'returnChoose(this)', $this->__('share.button.choose'))
                ->setWidth(50)
                ->setAlign('center');
    }
}

